//需求的接口
import request from '../request.js'
let get = request.get
let post = request.post
let loginApi = {
  /**
   * VERSION_YXKJ 版本号
   * */
getTxlList: (data) => get('/getList', data),
  // 单点登录
  //获取应用token
  getAppLogin: (data, name) => {
    appPost('/yxsystem/access_token', data).then((res) => {
      //获取token，用户基本信息
      uni.setStorage({
        key: 'appTokenTimestamp',
        data: Date.parse(new Date())
      })
      uni.setStorageSync('appToken', res.token)
      var param = {
        token: res.token
      }
      appPost('/yxsystem/userinfo', param).then((res) => {
        console.log('res', res)
        if (res.error_code == '00') {
          uni.setStorage({
            key: 'appPersonID',
            data: res.PersonID
          })
          uni.setStorage({
            key: 'appUserID',
            data: res.UserID
          })
          uni.setStorage({
            key: 'appPhone',
            data: res.Mobile
          })
          uni.setStorage({
            key: 'appdeptName',
            data: res.deptName
          })
          uni.setStorage({
            key: 'appPersonName',
            data: res.PersonName
          })
          uni.redirectTo({
            url: '/pages/' + name + '/index'
          })
        }
      })
    })
  },
  //宗教小程序单点登录
  systemTouristLoginWx: (data) => post('/yxsystem/api/monitor/systemTouristLogin', data, '', '', true),

  // 小程序单点
  bindUserInfoWx: (data) => get('/yxsystem/bindUserInfo', data, '', '', true)
}

export default loginApi

